package com.atguigu.utils;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

public class KeyWordUtil {

    public static List<String> splitKeyWord(String keyWord) throws IOException {

        //创建集合用于存放结果数据
        ArrayList<String> resultList = new ArrayList<>();

        //获取IK分词对象
        IKSegmenter ikSegmenter = new IKSegmenter(new StringReader(keyWord), false);

        Lexeme next = ikSegmenter.next();

        while (next != null) {
            String word = next.getLexemeText();
            resultList.add(word);

            next = ikSegmenter.next();
        }

        //返回结果
        return resultList;
    }

    public static void main(String[] args) throws IOException {

        System.out.println(splitKeyWord("上海大数据210927 Flink实时数仓项目DWS层"));

    }

}
